package boddaert.philippe.cashGame.site.splitgames;

import java.util.List;

import au.id.jericho.lib.html.Element;
import boddaert.philippe.cashGame.GameConfiguration;
import boddaert.philippe.cashGame.GameConfigurationCurrencyType;

public class WebGameParser extends
		boddaert.philippe.cashGame.parser.game.WebGameParser {

	@Override
	protected GameConfiguration getNewGameConfiguration() {
		return new GameConfiguration(SplitGames.NAME,
				GameConfigurationCurrencyType.POINT);
	}

	@Override
	protected double parseBestPrice(Element game) {
		List<Element> title = game.findAllElements("strong");
		for (Element element2 : title) {

			String[] split = element2.getContent().toString().split(" ");
			return Double.parseDouble(split[0]);
		}
		return -1;
	}

	@Override
	protected int parseNewAvailable(Element game) {
		return 0;
	}

	@Override
	protected int parseSecondHandAvailable(Element game) {
		return 0;
	}

	@Override
	protected String parseTitle(Element game) {
		List<Element> title = game.findAllElements("h3");
		Element link = (Element) title.get(0).getChildElements().get(0);
		return link.getContent().toString();
	}

	@Override
	protected String parseUrl(Element game) {
		List<Element> title = game.findAllElements("h3");
		Element link = (Element) title.get(0).getChildElements().get(0);
		return "http://www.splitgames.fr" + link.getAttributeValue("href");
	}

}
